﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;

namespace BusTrackerSystem.Utility
{
    /// <summary>
    /// Converts between a boolean or string value to a Visible or Collapsed Visibility.
    /// </summary>
    public class VisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value.GetType() == typeof(bool))
            {
                bool visible = (bool)value;
                if (visible)
                    return Visibility.Visible;
                else
                    return Visibility.Collapsed;
            }
            else if (value.GetType() == typeof(string))
            {
                string visible = (string)value;
                if (!value.Equals(""))
                    return Visibility.Visible;
                else
                    return Visibility.Collapsed;
            }
            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
